<?php
class Daotao_Model_Ajax extends Zend_Db_Table{
	
	protected $_name = 'nam_daotao_khoahoc';
	protected $_primary ='id';
	protected $_ids;
	
	public function countItemKhoahoc($arrParam = null, $options = null){
		$db = Zend_Registry::get('connectDb');
		//$db = Zend_Db::factory($adapter, $config);
	
		if($options['task'] == 'admin-list'){
			$select = $db	-> select()
							-> from('nam_daotao_khoahoc AS kh', array('COUNT(kh.id) AS totalItem'));
			$result = $db	-> fetchOne($select);
		}
	
		return $result;
	}
	
	public function listItemKhoahoc($arrParam = null, $options = null){
		$db = Zend_Registry::get('connectDb');
		//$db = Zend_Db::factory($adapter, $config);
	
		if($options['task'] == 'admin-list'){
	
			$paginator = $arrParam['paginator'];
	
			$select = $db	->	select()
							->	from('nam_daotao_khoahoc AS kh')
							->	order('kh.order ASC')
							->	order('kh.id ASC')
							-> 	where('kh.status = ?', 1);
	
			if($paginator['itemCountPerPage'] > 0){
				$page = $paginator['currentPage'];
				$rowCount = $paginator['itemCountPerPage'];
				$select->limitPage($page, $rowCount);
			}
			
			$result = $db	-> fetchAll($select);
		}
	
		return $result;
	
	}
}